



$.get('http://chst.vip:1234/api/getbrandtitle')
.then(res=>{
    // console.log(res);
    let {result:thing} = res;
    // console.log(thing);
    let html = "";
    thing.forEach((item,index) => {
        
        smallTab(index)   //调用下面封装的函数
        
        html+=`
        <li><h3>${item.brandTitle}</h3><p>▼</p></li>
        <div class="one"><span></span></div>
         `
    });

    $('#main ul').append(html);
      
    $('#main ul li').click(function(){
        $(this).next().finish().slideToggle(500)
    })


})

function smallTab(index){
    $.get(`http://chst.vip:1234/api/getbrand?brandtitleid=${index}`)
    .then(res=>{
        console.log(res);
        
        let {result:things} = res
        // console.log(things);
        let body = ""
        let id = 1
        things.forEach(item => {
            body+=`
            <a href="brand.html?title=${item.brandName}&brandtitleid=${item.brandId}">
            <div class="two"><span>${id}</span> <b>${item.brandName}</b></div>
            <div class="three">${item.brandInfo}</div>
            </a>
            `
            id++
        });
        //$('#main ul li ').eq(index).next().children().append(body)
        // console.log($('#main ul div span')[0]);
        $('#main ul .one>span').eq(index).append(body)
    })    
}




